<template>
  <div class="newslist-container">
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="item in newsList" :key="item.id">
        <router-link :to="'/home/newsList/' + com_name + '/' + item.id">
          <img class="mui-media-object mui-pull-left" :src="item.url">
          <div class="mui-media-body">
            <h2>{{ item.title }}</h2>
            <p class="mui-ellipsis">
              <span>发表于：{{ item.add_time | dateFormat }}</span>
              <span>点赞：0次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import { Toast } from 'mint-ui'

export default {
  data() {
    return {
      id: this.$route.params.id,
      newsList: [],
      com_name: 'newsinfo'
    };
  },
  created(){
    this.getNewsList()
  },
  methods: {
    getNewsList(){
      this.$http.get("newslist.php").then(result => {
        if (result.body.status === 0) {
          this.newsList = result.body.message;
        }else{
          Toast("获取新闻资讯失败！")
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.mui-table-view {
  li {
    h2 {
      font-size: 14px;
    }
    .mui-ellipsis {
      display: flex;
      justify-content: space-between;
      font-size: 12px;
      color: #226aff;
    }
  }
}
</style>
